package com.gtd

import com.gtd.account.user.*

import com.gtd.util.CryptoUtil

class TestController {

  def sessionStorageService

  def index = {
    def output = CryptoUtil.encrypt(params.input)
    render "${params.input} = ${output}}"
  }

  def login = {
    def params = [username:"abcdef", password:"123"]
    UserService userService = new UserService()
    if (userService.authenticate(params)) {
      render "OK"
    } else {
      render "FAIL"
    }
  }

  def sessLogin = {

    sessionStorageService.set(login, true)
    render sessionStorageService.get(login)
  }

  def sessLogout = {
    sessionStorageService.clear(login)
    if (!sessionStorageService.get(login)) {
      render "logout ok!"
    }
    
  }

  def logTest = {
    log.info("Info from log")
    render log
  }

}
